package cn.iocoder.yudao.module.biz.service.risk.riskMethodDetail;

import cn.iocoder.yudao.module.biz.controller.admin.risk.riskMethodDetail.vo.BizRiskMethodDetailExportReqVO;
import cn.iocoder.yudao.module.biz.dal.dataobject.risk.riskMethodDetail.BizRiskMethodDetailDO;
import cn.iocoder.yudao.module.biz.dal.mysql.risk.riskMethodDetail.BizRiskMethodDetailMapper;
import cn.iocoder.yudao.module.biz.enums.ErrorCodeConstants;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;

/**
 * 评级方法从 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
public class BizRiskMethodDetailServiceImpl implements BizRiskMethodDetailService {

    @Resource
    private BizRiskMethodDetailMapper riskMethodDetailMapper;

    @Override
    public void deleteRiskMethodDetail(String id) {
        // 校验存在
        this.validateRiskMethodDetailExists(id);
        // 删除
        riskMethodDetailMapper.deleteById(id);
    }
    private void validateRiskMethodDetailExists(String id) {
        if (riskMethodDetailMapper.selectById(id) == null) {
            throw exception(ErrorCodeConstants.RISK_METHOD_DETAIL_NOT_EXISTS);
        }
    }
    @Override
    public List<BizRiskMethodDetailDO> getRiskMethodDetailList(Collection<String> ids) {
        return riskMethodDetailMapper.selectBatchIds(ids);
    }

    @Override
    public List<BizRiskMethodDetailDO> getRiskMethodDetailList(String methodNameId,String type) {
        BizRiskMethodDetailExportReqVO vo = new BizRiskMethodDetailExportReqVO();
        vo.setMethodNameId(methodNameId);
        vo.setType(type);
        return riskMethodDetailMapper.selectList(vo);
    }

    @Override
    public List<BizRiskMethodDetailDO> getRiskMethodDetailType(String methodNameId) {
        return riskMethodDetailMapper.getRiskMethodDetailType(methodNameId);
    }
    @Override
    public List<BizRiskMethodDetailDO> getRiskMethodDetailList(BizRiskMethodDetailExportReqVO exportReqVO) {
        return riskMethodDetailMapper.selectList(exportReqVO);
    }

}
